	#include<stdio.h>
int majorityElement(int* nums, int numsSize)
{
    int count = 1;
    int tmp = nums[0];
    for (int i = 1; i < numsSize; i++) {
        if (tmp = nums[i])
            count++;
        else {
            count--;
            if (count == 0)
                tmp = nums[i + 1];
        }
    }
    return tmp;
}
int main()
{
    int nums[] = {1,1,1,2,2,2,1};
    int sz = sizeof(nums) / sizeof(nums[0]);
    printf("%d\n", majorityElement(nums, sz));
    return 0;
}